﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameJam2012
{
    /// <summary>
    /// The base class for mobile objects in a level, such as the player character
    /// </summary>
    public class Entity
    {
        public Vector2 Position;
        protected Texture2D sprite;
        protected Color color = Color.White;
        public Vector2 ScreenPosition = Vector2.Zero;
        public bool Dead = false;
        protected Level currentLevel;

        public virtual void Update(GameTime gameTime, Level level)
        {
            currentLevel = level;
        }

        /// <summary>
        /// Draws the entity
        /// </summary>
        /// <param name="spriteBatch">The SpriteBatch to use for drawing</param>
        /// <param name="xOffset">The drawing offset in the x direction</param>
        /// <param name="yOffset">The drawing offset in the y direction</param>
        /// <param name="tint">The color to tint the sprite by</param>
        public virtual void Draw(SpriteBatch spriteBatch, float xOffset, float yOffset, Color tint)
        {
            ScreenPosition = Position + new Vector2(xOffset, yOffset);
        }

        public virtual bool CheckCollisionWith(FloatRectangle bound)
        {
            FloatRectangle myBound = GetBoundingBox();
            if(myBound == null || bound == null) return false;
            return myBound.Intersects(bound);
        }

        public virtual void CollideWith(Entity e)
        {

        }

        public virtual FloatRectangle GetBoundingBox()
        {
            return null;
        }

        public virtual void Kill()
        {
            Dead = true;
        }
    }
}
